导航菜单
首页 >  掩码 MapalerPixivUserBatchDownload Wiki GitHub  > 掩码 · Mapaler/PixivUserBatchDownload Wiki · GitHub

掩码 · Mapaler/PixivUserBatchDownload Wiki · GitHub

目前仅有“下载目录”、“保存路径”、“自定义掩码”内可以使用掩码控制。

掩码的书写方式为“%{掩码名}”,目前不支持转义符,因此掩码名内不能有“}”字符。

2017年4月30日 从v5.2.8版本开始,支持“\{”→“{”、“\}”→“}”、“\\”→“\”三个转义符,以便能在掩码内书写函数。

下载时,程序会自动将掩码替换为该掩码对应的内容。

主要掩码对象

掩码主要使用user与illust两个对象,分别储存的是当前用户的信息和该条图片的信息;以及page这个数字,表示当前的多图页数/动图帧数(单图只有第一张,为0)。

掩码中使用对象的调用方式来获取信息,支持多层调用与数组。简单给不懂JS的人介绍一下,下面示例代码中大括号“{}”表示一个对象,中括号“[]”表示一个数组。访问子对象使用英文句号“.”连接子对象的属性名称,访问数组元素使用中括号加数组下标“[n]”(从0开始),可以用数组名.length返回数组长度,字符串.length返回字符串长度。

如%{user.user.name}返回的就是当前下载用户的昵称,%{user.user.profile_image_urls.medium}返回的是当前下载用户的头像图片地址。

以默认的下载路径做讲解示例:%{illust.user.id}/%{illust.filename}%{page}.%{illust.extention}返回的结果为“插画的作者id/插画原文件文件名+页数.插画的扩展名”。软件会自动将中间的那层斜杠转换为一层文件夹,所以就成了作者id是一层文件夹,里面是插画源文件的名字(即id加页数)。如果希望使用作者的昵称、插画的名称来命名,可以使用%{illust.user.name}/%{illust.title}_p%{page}.%{illust.extention}

注:illust.filename和illust.extention不是P站原生返回的,是我自己从原图地址中截取添加的。illust.filename是原始文件名去掉张数的部分。illust.extention是插画源文件的扩展名,因为P站上传多图的扩展名必须一致,因此不需要每页设置不同的扩展名。

名称命名结果名称命名

user对象示例

user.user是当前下载用户的基本信息,user.profile是用户的个人资料,user.workspace是用户的操作环境资料

{"user": {"id": 3896348,"name": "枫谷剑仙","account": "mapaler","profile_image_urls": {"medium": "https://i2.pixiv.net/user-profile/img/2016/04/22/17/52/13/10835493_0604d937120e2b0f68dd87474d05fe71_170.png"},"comment": "东方厨,但并不会画","is_followed": false},"profile": {"webpage": "http://www.mapaler.com","gender": "male","birth": "1991-07-10","region": "China","job": "技术关联","total_follow_users": 71,"total_follower": 10,"total_mypixiv_users": 5,"total_illusts": 16,"total_manga": 1,"total_novels": 0,"total_illust_bookmarks_public": 282,"background_image_url": "https://source.pixiv.net/common/images/bg/star02.png","twitter_account": "","twitter_url": null,"is_premium": false},"workspace": {"pc": "买的","monitor": "带的","tool": "下的","scanner": "坏的","tablet": "没的","mouse": "淘的","printer": "没的","desktop": "键盘鼠标显示器","music": "osu!或CM东方集合","desk": "木的","chair": "布的","comment": "中国有句话叫做闷声大发财,因此无可奉告。","workspace_image_url": "http://i1.pixiv.net/workspace/img/2016/04/22/18/48/47/3896348_918334803489f5f2664b3050b44eab23.jpg"}}illust对象示例

illust返回当前下载每条图片的信息。

需注意illust.user返回的是该图片的作者,user.user返回的是当前用户,如果下载的是该用户的作品,那么它们往往是一致的,而如果下载的是该用户收藏其他用户的作品,那么两者就会不同了。也就是说如果按照画师分类,就使用illust.user来命名,如果按照收藏者分类,就使用user.user来命名。

P站作品有三个类型,插画、漫画、动画,区别如下:illust.type的值分别为"illust"、"manga"、"ugoira"动图会多一个illust.ugoira_metadata子对象,非动图没有这个子对象。

插画、漫画都可能是单图或多图。单图与动画,illust.page_count为1,原图地址在illust.meta_single_page.original_image_url,而多图的illust.page_count大于1,原图地址在illust.meta_pages[0].image_urls.original。

插画示例{"id": 30592809,"title": "东娘奔月","type": "illust","image_urls": {"square_medium": "https://i.pximg.net/c/360x360_70/img-master/img/2012/10/05/18/44/56/30592809_p0_square1200.jpg","medium": "https://i.pximg.net/c/540x540_70/img-master/img/2012/10/05/18/44/56/30592809_p0_master1200.jpg","large": "https://i.pximg.net/c/600x1200_90/img-master/img/2012/10/05/18/44/56/30592809_p0_master1200.jpg"},"caption": "“东东秋季绘图大赛 灬qiu灬les't go!~”参赛作品","restrict": 0,"user": {"id": 3896348,"name": "枫谷剑仙","account": "mapaler","profile_image_urls": {"medium": "https://i2.pixiv.net/user-profile/img/2016/04/22/17/52/13/10835493_0604d937120e2b0f68dd87474d05fe71_170.png"},"is_followed": false},"tags": [{"name": "动漫东东"}, //访问这里需要使用illust.tags[0].name{"name": "秋季"}, {"name": "东东娘"},{"name": "鲸鱼"},{"name": "鼠绘"}],"tools": ["Illustrator"],"create_date": "2012-10-05T18:44:56+09:00","page_count": 1,"width": 6400,"height": 4000,"sanity_level": 2,"meta_single_page": {"original_image_url": "https://i2.pixiv.net/img-original/img/2012/10/05/18/44/56/30592809_p0.jpg"},"meta_pages": [],"filename": "30592809_p","extention": "jpg","total_view": 185,"total_bookmarks": 0,"is_bookmarked": false,"visible": true,"is_muted": false,"total_comments": 0}插画(多图)示例{"id": 56455565,"title": "步步高学习机9588绘画(2009)","type": "illust","image_urls": {"square_medium": "https://i.pximg.net/c/360x360_70/img-master/img/2016/04/21/13/23/34/56455565_p0_square1200.jpg","medium": "https://i.pximg.net/c/540x540_70/img-master/img/2016/04/21/13/23/34/56455565_p0_master1200.jpg","large": "https://i.pximg.net/c/600x1200_90/img-master/img/2016/04/21/13/23/34/56455565_p0_master1200.jpg"},"caption": "步步高@ibox9588(BBK@ibox9588, a learning machine released in 2006)上画的,虽然是电容屏,但没有渐变色,无法放大,只有单像素线条和油漆桶,比WinXP的画图还难用。按顺序2009年2010年2011年(未完成)各一张。","restrict": 0,"user": {"id": 3896348,"name": "枫谷剑仙","account": "mapaler","profile_image_urls": {"medium": "https://i2.pixiv.net/user-profile/img/2016/04/22/17/52/13/10835493_0604d937120e2b0f68dd87474d05fe71_170.png"},"is_followed": false},"tags": [{"name": "セーラー服"},{"name": "手機繪"}],"tools": [],"create_date": "2016-04-21T13:23:34+09:00","page_count": 3,"width": 240,"height": 247,"sanity_level": 2,"meta_single_page": {},"meta_pages": [ //多图每一页的图像信息都在这里{"image_urls": {"square_medium": "https://i.pximg.net/c/360x360_70/img-master/img/2016/04/21/13/23/34/56455565_p0_square1200.jpg","medium": "https://i.pximg.net/c/540x540_70/img-master/img/2016/04/21/13/23/34/56455565_p0_master1200.jpg","large": "https://i.pximg.net/c/600x1200_90/img-master/img/2016/04/21/13/23/34/56455565_p0_master1200.jpg","original": "https://i2.pixiv.net/img-original/img/2016/04/21/13/23/34/56455565_p0.png"}},{"image_urls": {"square_medium": "https://i.pximg.net/c/360x360_70/img-master/img/2016/04/21/13/23/34/56455565_p1_square1200.jpg","medium": "https://i.pximg.net/c/540x540_70/img-master/img/2016/04/21/13/23/34/56455565_p1_master1200.jpg","large": "https://i.pximg.net/c/600x1200_90/img-master/img/2016/04/21/13/23/34/56455565_p1_master1200.jpg","original": "https://i2.pixiv.net/img-original/img/2016/04/21/13/23/34/56455565_p1.png"}},{"image_urls": {"square_medium": "https://i.pximg.net/c/360x360_70/img-master/img/2016/04/21/13/23/34/56455565_p2_square1200.jpg","medium": "https://i.pximg.net/c/540x540_70/img-master/img/2016/04/21/13/23/34/56455565_p2_master1200.jpg","large": "https://i.pximg.net/c/600x1200_90/img-master/img/2016/04/21/13/23/34/56455565_p2_master1200.jpg","original": "https://i2.pixiv.net/img-original/img/2016/04/21/13/23/34/56455565_p2.png"}}],"filename": "56455565_p","extention": "png","total_view": 124,"total_bookmarks": 0,"is_bookmarked": false,"visible": true,"is_muted": false,"total_comments": 1}动画示例{"id": 49709638,"title": "东娘厚郁稲 - 动态","type": "ugoira","image_urls": {"square_medium": "https://i.pximg.net/c/360x360_70/img-master/img/2015/04/07/03/32/03/49709638_square1200.jpg","medium": "https://i.pximg.net/c/540x540_70/img-master/img/2015/04/07/03/32/03/49709638_master1200.jpg","large": "https://i.pximg.net/c/600x1200_90/img-master/img/2015/04/07/03/32/03/49709638_master1200.jpg"},"caption": "电波洗脑,视频地址是 http://www.bilibili.tv/video/av936752","restrict": 0,"user": {"id": 3896348,"name": "枫谷剑仙","account": "mapaler","profile_image_urls": {"medium": "https://i2.pixiv.net/user-profile/img/2016/04/22/17/52/13/10835493_0604d937120e2b0f68dd87474d05fe71_170.png"},"is_followed": false},"tags": [{"name": "うごイラ"},{"name": "动漫东东"},{"name": "东东娘"},{"name": "鼠绘"}],"tools": ["Fireworks"],"create_date": "2015-04-07T03:32:03+09:00","page_count": 1,"width": 1024,"height": 768,"sanity_level": 2,"meta_single_page": {"original_image_url": "https://i3.pixiv.net/img-original/img/2015/04/07/03/32/03/49709638_ugoira0.png"},"meta_pages": [],"filename": "49709638_ugoira","extention": "png","total_view": 174,"total_bookmarks": 2,"is_bookmarked": false,"visible": true,"is_muted": false,"total_comments": 1,"ugoira_metadata": { //动画增加的帧信息"zip_urls": {"medium": "https://i3.pixiv.net/img-zip-ugoira/img/2015/04/07/03/32/03/49709638_ugoira600x600.zip"},"frames": [ //获取动图的帧数使用 illust.ugoira_metadata.frames.length,动图是不会反回所有的原图信息的,所以PUBD下载时是将第一张原图地址的帧数修改来获取后面的图片的。{"file": "000000.jpg","delay": 60},{"file": "000001.jpg","delay": 60},{"file": "000002.jpg","delay": 60},{"file": "000003.jpg","delay": 60},{"file": "000004.jpg","delay": 60},{"file": "000005.jpg","delay": 60}]}}漫画(单图)及权限作品示例

该示例为仅自己可见的图片的代码,凡是高权限作品,图片url中都会多一段加密的代码。

{"id": 60738695,"title": "开发用测试图片","type": "manga","image_urls": { //凡是高权限作品,图片url中都会多一段加密的代码"square_medium": "https://i.pximg.net/c/360x360_70/img-master/img/2017/01/03/12/08/24/60738695-1255fafb31361ff75c26a5944fff105a_p0_square1200.jpg","medium": "https://i.pximg.net/c/540x540_70/img-master/img/2017/01/03/12/08/24/60738695-1255fafb31361ff75c26a5944fff105a_p0_master1200.jpg","large": "https://i.pximg.net/c/600x1200_90/img-master/img/2017/01/03/12/08/24/60738695-1255fafb31361ff75c26a5944fff105a_p0_master1200.jpg"},"caption": "开发脚本时候需要用到的测试图片","restrict": 2, //注:0表示公开,1表示仅好友可见,2表示仅自己可见"user": {"id": 3896348,"name": "枫谷剑仙","account": "mapaler","profile_image_urls": {"medium": "https://i2.pixiv.net/user-profile/img/2016/04/22/17/52/13/10835493_0604d937120e2b0f68dd87474d05fe71_170.png"},"is_followed": false},"tags": [{"name": "漫画"}],"tools": ["Fireworks"],"create_date": "2017-01-03T12:08:24+09:00","page_count": 1,"width": 604,"height": 486,"sanity_level": 2,"meta_single_page": {"original_image_url": "https://i4.pixiv.net/img-original/img/2017/01/03/12/08/24/60738695-1255fafb31361ff75c26a5944fff105a_p0.png"},"meta_pages": [],"filename": "60738695-1255fafb31361ff75c26a5944fff105a_p","extention": "png","total_view": 0,"total_bookmarks": 0,"is_bookmarked": false,"visible": true,"is_muted": false,"total_comments": 0}原理及高级用法

警告:此方式需要具有JS或类似编程知识才可理解,一般用户请勿使用

这次PUBD v5为了增加自定义性,对于掩码不再是固定提供,实际功能的实现是使用JS的eval()函数直接解析掩码名。因此掩码名其实是一段JS语句。

页数从1开始

所以可以衍生出高级用法,比如%{page+1}就能得到比%{page}大1的值。

逻辑判断示例

使用条件运算符完成让多图和动图放到以自己id命名的一个文件夹内。掩码名为(illust.page_count>1||illust.ugoira_metadata)?"/" + illust.id:"",意思就是当作品的页数大于一或者是动图时(动图才有ugoira_metadata这个子对象)输出“/作品ID”,否则输出空白“”,完整掩码如下{illust.user.id}%{(illust.page_count>1||illust.ugoira_metadata)?"/" + illust.id:""}/%{illust.filename}%{page}.%{illust.extention}

不变的作者名称

有些人想把作者名称加入到文件夹名称里面去,但是很多作者经常参展,会在名称后面加上展会位置,就导致了下载路径发生变化而重复下载,以前的解决办法是只使用作者数字id,而这也确实缺少了辨识度。

现在V5版就可以在一定程度上解决这一问题,因为我发现大部分画师都会用“昵称@展会名”的方式来改名,那么我们只需要取@符号前的即可是固定不变的作者名了。首先通过illust.user.name获取画师名,然后画师名.split("@")会得到以@字符分割的字符串数组,然后数组[0]取第一个对象。全部连起来就是illust.user.name.split("@")[0]。

于是如果一个画师名叫“枫谷剑仙@C128 第2天东区-53a”,%{illust.user.name.split("@")[0]}就会输出“枫谷剑仙”。

哈?你说你喜欢的画师不是用@来分割的,那关我鸟事?

作品发布时间

JS语句illust.create_date可以获取作品的创建时间世界时字符串(重

相关推荐: